Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix call undefined delegate #1149

Merged
merged 12 commits into from
Jul 19, 2023
Merged

Conversation

ScriptedAlchemy
Copy link
Member

If delegate module contains additional dependency modules that are not in module cache at time of invocation, webpack will crash with "call of undefined" error when attempting to execute missing module reference

@ScriptedAlchemy ScriptedAlchemy force-pushed the fix_call_undefined_delegate branch from 75d7a16 to d657030 Compare July 18, 2023 18:32
re-export underlaying utilities to allow for less fragmentation of package versions for the sake of access to these tools
@@ -1,13 +1,11 @@
import {importDelegatedModule} from "@module-federation/utilities/src/utils/importDelegatedModule";
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testing eager import which should break application

@@ -457,7 +457,9 @@ class FederationStatsPlugin {
// Iterate over each dependency within the block.
for (const dep of blockmodule.dependencies) {
// Get the module that corresponds to the dependency.
const { module } = compilation.moduleGraph.getConnection(dep);
const connection = compilation.moduleGraph.getConnection(dep);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only search valid module connections to relocate in graph

@@ -2,7 +2,7 @@

import type { Compiler, container } from 'webpack';
import type { ModuleFederationPluginOptions } from '../types';
import { extractUrlAndGlobal } from '@module-federation/utilities';
import { extractUrlAndGlobal } from '@module-federation/utilities/src/utils/pure';
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move pure utils to pure folder for smaller footprint of code moved into runtime module as eager

* fix: prevent module graph connection conflict

I remove eager modules from remote, but in doing so also removes dependencies of delegate moduels, this preserves dependency tree of delegate module and removes all other eager references from eager:true

* test: fix mock of delegate module eager flag

* test: fix mock of delegate module eager flag

* test: fix mock of delegate module eager flag
@ScriptedAlchemy ScriptedAlchemy merged commit 87a5896 into main Jul 19, 2023
@ScriptedAlchemy ScriptedAlchemy deleted the fix_call_undefined_delegate branch July 19, 2023 00:17
RussellCanfield pushed a commit to RussellCanfield/nextjs-mf that referenced this pull request Aug 26, 2023
* fix: thrown error during chunk correlation of empty graph connection

* fix: call of undefined errors in delegate modules

* test: fix tests of delegate plugin

* chore: prettier

* refactor: improve package fragmentation

re-export underlaying utilities to allow for less fragmentation of package versions for the sake of access to these tools

* fix: prevent module graph connection conflict (module-federation#1151)

* fix: prevent module graph connection conflict

I remove eager modules from remote, but in doing so also removes dependencies of delegate moduels, this preserves dependency tree of delegate module and removes all other eager references from eager:true

* test: fix mock of delegate module eager flag

* test: fix mock of delegate module eager flag

* test: fix mock of delegate module eager flag

* feat: support next/image

* style:lint fix

* style:lint fix

* style:lint fix
Copy link
Contributor

🎉 This PR is included in version 1.0.0-canary.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant